-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Best Practices] Add check for TimeSeries
unit follows CMIXF-12
convention
#281
base: dev
Are you sure you want to change the base?
[Best Practices] Add check for TimeSeries
unit follows CMIXF-12
convention
#281
Conversation
…-12' into add_check_for_unit_follows_CMIXF-12
Double check what can and cannot be changed for units |
Co-authored-by: Cody Baker <[email protected]>
Best Practice: :ref:`best_practice_units_of_measurement` | ||
""" | ||
|
||
# Early return for arbitrary units that are unknown or unavailable. | ||
if time_series.unit == "a.u.": | ||
return | ||
|
||
lexer = CMIXFLexer() | ||
tokens = lexer.tokenize(time_series.unit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lexer.tokenize()
a generator
object, when a bad character is found it immediately raises an error. e.g.
tokens = lexer.tokenize("ta")
next(tokens)
would return the recognized token value for unit t
Token(type='UNITC', value='t', lineno=1, index=0)
next(tokens)
would return:
{ValueError}Line 1: Bad character 'a'
* - :py:class:`~pynwb.retinotopy.AxisMap` | ||
- "o" | ||
- Degrees |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not TimeSeries
but I thought could be good to include for example for representing degrees?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CompassDirection is more typical for that as an example (be sure to include radians as well)
Codecov Report
@@ Coverage Diff @@
## dev #281 +/- ##
==========================================
+ Coverage 93.95% 94.02% +0.06%
==========================================
Files 20 20
Lines 1026 1037 +11
==========================================
+ Hits 964 975 +11
Misses 62 62
Flags with carried forward coverage won't be shown. Click here to find out more.
|
can we hold off on this? I don't know if we want to use CMIXF |
Motivation
WIP
Proposing a new check for
TimeSeries
that checks if unit formatting complies with the CMIXF-12 convention.#208
How to test the behavior?
Checklist
black
format? If not, simplypip install black
and runblack .
inside your fork.fix #XX
whereXX
is the issue number?